﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class VideoClipPlay : System.Web.UI.Page
{
    public string FilePath { get; set; }
    public string Poster { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        string vid_s = Request.QueryString["vid"];
        int vid;
        bool t = Int32.TryParse(vid_s, out vid);
        if (t)
        {
            Sharemp3DataContext db = new Sharemp3DataContext();

            var selectedMusic = (from i in db.VideoClips
                                 where i.VideoID == vid
                                 select new
                                 {
                                     VideoID = i.VideoID,
                                     FilePath = i.FilePath,
                                     OGV = i.OGV,
                                     WEBMV = i.WEBMV,
                                     Poster = i.Poster,
                                     Title = i.Title,
                                     AlbumID = i.AlbumID,
                                     AlbumName = i.Album.AlbumName,
                                     ArtistID = i.Album.ArtistID,
                                     ArtistName = i.Album.Artist.ArtistName,
                                     Description = i.Album.Artist.Description,
                                     ImageCover = i.Album.Artist.ImageCover,
                                     GenresID = i.GenresID,
                                     GenresName = i.Genre.GenresName,
                                     Rating = i.Rating,
                                     AddDate = i.AddDate
                                 }).First();

            titleDetails.InnerText = selectedMusic.Title + " - " + selectedMusic.ArtistName;
            musicTittle.InnerText = selectedMusic.Title + " - " + selectedMusic.AddDate.Value.Year;

            artistCover.Src = selectedMusic.ImageCover;
            artistCover.Alt = artistname.InnerText = selectedMusic.ArtistName;
            artistname.HRef= artistLnk.HRef = "ArtistMusic.aspx?aid=" + selectedMusic.ArtistID;
            artistdescription.InnerText = selectedMusic.Description;
            FilePath = selectedMusic.FilePath;
            Poster = selectedMusic.Poster;

            var album = db.Albums.Where(i => i.ArtistID == selectedMusic.ArtistID).Take(10);
            Rpt_AlbumArtist.DataSource = album;
            Rpt_AlbumArtist.DataBind();
        }
    }
}